package com.example.voting_master.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.voting_master.entity.Candidate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface CandidateMapper extends BaseMapper<Candidate> {

    @Select("SELECT can.*,cvs.votes From candidate as can,candidate_vote_stats as cvs,vote_theme as vt "+
    "WHERE can.id = cvs.candidate_id AND cvs.theme_id = vt.id AND vt.id = #{themeId}")
    List<Candidate> selectByThemeId(@Param("themeId") Long themeId);
}
